package com.alibaba.otter.shared.communication.core.impl.dubbo;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.utils.SerializeCheckStatus;
import org.apache.dubbo.common.utils.SerializeSecurityManager;
import org.apache.dubbo.rpc.model.FrameworkModel;

import java.net.InetAddress;
import java.net.InetSocketAddress;

public class DubboEnv {


    public static void config(){
        System.setProperty(CommonConstants.SystemProperty.SERIALIZATION_SECURITY_CHECK_KEY, "false");
        System.setProperty(CommonConstants.SERIALIZE_CHECK_STATUS_KEY, SerializeCheckStatus.WARN.name());
        System.setProperty("dubbo.application.qos.enable", "false");
        SerializeSecurityManager securityManager = FrameworkModel.defaultModel().defaultApplication()
                .getBeanFactory().getOrRegisterBean(SerializeSecurityManager.class);
        securityManager.setDefaultCheckStatus(SerializeCheckStatus.WARN);
        securityManager.setCheckSerializable(false);
        securityManager.setCheckStatus(SerializeCheckStatus.WARN);
        securityManager.addToAllowed(InetAddress.class.getName()); // 添加 InetAddress
        securityManager.addToAllowed(InetSocketAddress.class.getName());
    }
}
